package com.sgcc.pda.frme.protocol.ws.sendbean;

import androidx.annotation.NonNull;

import com.sgcc.pda.frme.protocol.ws.DataConvert;

/**
 * @author guorongxin
 * @date 2020/3/25
 * @fileName hw
 * @Description
 * @special 如修改此类请在下方添加备注并告知创建者，谢谢配合！
 * @VERSION 1.0
 */
public class GBReadDataParams200F {

    /**
     * 安全标识
     */
    private String safeType;

    /**
     * 数据区
     */
    private String data;

    /**
     * 偏移
     */
    private String offset;

    /**
     * 长度
     */
    private String length;

    /**
     * 标签访问密码
     */
    private String password;

    public String getSafeType() {
        return safeType;
    }

    public void setSafeType(String safeType) {
        this.safeType = safeType;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getOffset() {
        return offset;
    }

    public void setOffset(String offset) {
        this.offset = offset;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @NonNull
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (null == safeType) {
            return null;
        }
        safeType = DataConvert.toHexString(Integer.valueOf(safeType), 1);
        sb.append(safeType);

        if (null == data) {
            return null;
        }
        data = DataConvert.toHexString(Integer.valueOf(data), 1);
        sb.append(data);

        if (null == offset) {
            return null;
        }
        offset = DataConvert.toHexString(Integer.valueOf(offset), 2);
        sb.append(DataConvert.strReverse(offset, 0, offset.length()));


        if (null == length) {
            return null;

        }
        length = DataConvert.toHexString(Integer.valueOf(length), 1);
        sb.append(length);

        if (null == password) {
            return null;
        }
        password = DataConvert.toHexString(Integer.valueOf(password), 4);
        sb.append(DataConvert.strReverse(password, 0, password.length()));
        return sb.toString();
    }
}
